/**
 * creater:chuanpeng.zhu@dhc.com.cn
 * create time:2016-06-01 14:47:00
 * describe:弹出窗口实例
 */
APP.controller('PopupExampleController', ['$scope', 'PopupExampleService', 'PopupService',
  function ($scope, PopupExampleService, PopupService) {

    /***变量声明***/
    $scope.username = undefined;
    $scope.password = undefined;

    /**
     * 初始化函数
     */
    $scope.init = function () {

    };

    /**
     * 弹窗实例
     */
    $scope.exampleShowToast = function () {
      PopupService.showToast('你好！');
    };
    $scope.exampleShowAlert = function () {
      PopupService.showAlert('你好，我是Alert弹窗');
    };
    $scope.exampleShowConfirm = function () {
      PopupService.showConfirm('This is Title', 'This is Message!', function (res) {
        if (res) {
          PopupService.showToast('这里是成功回调方法');

        }
      }, '有钱，任性');
    };


    /*
     $scope.init();//如果页面缓存则用此方法初始化
     */
    $scope.$on('$ionicView.beforeEnter', function () {
      $scope.init();
    });
  }
]);

/**
 * creater:chuanpeng.zhu@dhc.com.cn
 * create time:2016-06-01 14:47:00
 * describe:弹出窗口实例
 */
APP.service('PopupExampleService', ['$http', 'UrlService', function ($http, UrlService) {
  /**
   * 登录方法
   * @param username  登录用户名
   * @param password  登录密码
   */
  this.doLogin = function (username, password) {
    var param = {
      username: username,
      password: password
    };
    $http.post(UrlService.get('LOGIN'), param);
  }

}]);
